﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ControlCustomizition
{
        public partial class Calculator : Window
        {
                public Calculator()
                {
                        InitializeComponent();
                }

                private void BtnCalculate_Click(object sender, RoutedEventArgs e)
                {
                        if (Double.TryParse(TbxFirstNumber.Text, out Double FirstDouble) & Double.TryParse(TbxSecondNumber.Text, out Double SecondDouble))
                        {
                                if (CbbOperator.Text == "÷" & SecondDouble != 0)
                                {
                                        TbxResult.Text = (FirstDouble / SecondDouble).ToString();
                                        SnackbarError.IsActive = false;
                                }
                                else if (CbbOperator.Text == "+")
                                {
                                        TbxResult.Text = (FirstDouble + SecondDouble).ToString();
                                        SnackbarError.IsActive = false;
                                }
                                else if ((CbbOperator.Text == "-"))
                                {
                                        TbxResult.Text = (FirstDouble - SecondDouble).ToString();
                                        SnackbarError.IsActive = false;
                                }
                                else if ((CbbOperator.Text == "×"))
                                {
                                        TbxResult.Text = (FirstDouble * SecondDouble).ToString();
                                        SnackbarError.IsActive = false;
                                }
                                else
                                {
                                        SnackbarError.IsActive = true;
                                }
                        }
                        else SnackbarError.IsActive = true;
                }
        }
}
